import React, { useState, useEffect } from 'react'
import { Table, Tag } from 'antd'
import request from '@/utils/request'

export default () => {
    const [tableData,setTableData] = useState({ list: [], total: 0 })
    const columns: any = [
        {
            title: '名称',
            dataIndex: 'title',
            render: (text: any) => <a>{text}</a>,
        },
        {
            title: '手机号',
            dataIndex: 'mobile',
        },
        {
            title: '地址信息',
            dataIndex: 'address',

        },
        {
            title: '是否默认地址',
            dataIndex: 'is_default',
            align: "center",
            render: (text: any) => <Tag color="cyan">{text?"是":"否"}</Tag>,
        },
    ];

    const data = [
        {
            id: 1,
            title: '地址名称',
            mobile: "15555124010",
            address: "北京市 东城区 润坤大厦",
            is_default: "是",
        }
    ];
    useEffect(() => {
        request(`/member/address-list`).then((result) => {
            if (result.code === 200) {
                setTableData({ list: result.data, total: result.total })
            }
        })
    }, [])

    return (
        <div>
            <Table columns={columns} dataSource={tableData.list} rowKey="id" />
        </div>
    )
}